import Vue from 'vue'
import Vuex from 'vuex'

import d2admin from './modules/d2admin'
const filesPage = require.context('@/views', true, /(store|\.store)\.js$/)
const modules = {}
filesPage.keys().forEach(key => {
  modules[key.match(/plugin\/(\S*)\.store\.js$/)[1]] = filesPage(key).default
})

Vue.use(Vuex)

export default new Vuex.Store({
  modules: {
    d2admin,
    ...modules
  }
})
